'use strict';

/**
 * 商城
 * GoodsDetailController
 * @constructor
 */
App.controller('GoodsDetailController', function($scope, $http, $stateParams) {
	
	$scope.fetchGoodsDetail = function() {
        $http.get('Store/goodsDetail/' + $stateParams.goodsId + '.json').success(function(goodsDetail){
            $scope.goodsDetail = goodsDetail;
            console.log(goodsDetail);
        });
    };
    
    $scope.fetchGoodsDetail();
	
    //下拉刷新页面
    $scope.doRefresh = function() {
    	 $http.get('Store/goodsDetail/' + $stateParams.goodsId + '.json').success(function(goodsDetail){
             $scope.goodsDetail = goodsDetail;
             console.log(goodsDetail);
         })
         .finally(function() {
           // Stop the ion-refresher from spinning
           $scope.$broadcast('scroll.refreshComplete');
         });
     };
      
	 $scope.addToCard = function() {
	     $http.get('Cart/addToCart/' + $scope.goodsDetail.id + '.json').success(function(isSuccess){
	         console.log(isSuccess);
	     });
	 };
});


